﻿namespace Calendar
{
    using System;
    using System.Data;

    public class DataBoundAppointment : Appointment
    {
        private DataRow row;

        public DataBoundAppointment(DataRow row)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }
            this.row = row;
        }

        protected override void OnBorderColorChanged()
        {
            base.OnBorderColorChanged();
            this.row["BorderColor"] = base.BorderColor.ToArgb();
        }

        protected override void OnColorChanged()
        {
            base.OnColorChanged();
            this.row["Color"] = base.Color.ToArgb();
        }

        protected override void OnEndDateChanged()
        {
            base.OnEndDateChanged();
            this.row["EndDate"] = base.EndDate;
        }

        protected override void OnLockedChanged()
        {
            base.OnLockedChanged();
            this.row["Locked"] = base.Locked;
        }

        protected override void OnStartDateChanged()
        {
            base.OnStartDateChanged();
            this.row["StartDate"] = base.StartDate;
        }

        protected override void OnTextColorChanged()
        {
            base.OnTextColorChanged();
            this.row["TextColor"] = base.TextColor.ToArgb();
        }

        protected override void OnTitleChanged()
        {
            base.OnTitleChanged();
            this.row["Title"] = base.Title;
        }

        public DataRow Row
        {
            get
            {
                return this.row;
            }
        }
    }
}

